<?php
class DeliveryAction extends Action {
    public function __construct() {
        parent::__construct();
    }

    public function index() {
        parent::page();
        $this->tpl->assign('allDelivery',$this->model->findAll());
        $this->tpl->display(SMARTY_ADMIN.'delivery/show.html');
    }
    public function add() {
        if(isset($_POST['send'])) $this->model->add() ? $this->redirect->succ('?a=delivery','物流新增成功!') : $this->redirect->error('系统出错,物流新增失败！');
        $this->tpl->display(SMARTY_ADMIN.'delivery/add.html');
    }
    public function update() {
        if(isset($_POST['send'])) $this->model->update() ? $this->redirect->succ(Tool::getPrevPage(),'物流修改成功!') : $this->redirect->error('物流修改失败!');
        if(isset($_GET['id'])) {
            $this->tpl->assign('oneDelivery',$this->model->findOne());
            $this->tpl->display(SMARTY_ADMIN.'delivery/update.html');
        }

    }
    public function delete() {
        $this->model->delete() ? $this->redirect->succ(Tool::getPrevPage(),'物流删除成功!') : $this->redirect->error('系统出错，物流删除失败!');
    }

    public function ajaxCheckName() {
        $this->model->ajaxCheckName();
    }
}


?>